<?php


namespace app\webs\controller;


use app\common\controller\Api;
use app\webs\model\NewsModel;

class News extends Api
{
    public function index()
    {
        $zx = NewsModel::order('id','DESC')
            ->where('switch',1)
            ->field('id,text,create_time,status')
            ->where('status','=','opt0')
            ->find();
        $dt = NewsModel::order('id','DESC')
            ->where('switch',1)
            ->field('id,text,create_time,status')
            ->where('status','=','opt1')
            ->find();
        if (!$zx && !$dt){
            $this->error('查询失败');
        }
        $this->success('查询成功',[
            '资讯' => $zx,
            '动态' => $dt
        ]);
    }

}